package hot_100;

public class 买卖股票的最佳时机 {
    public static void main(String[] args) {

    }

    public int maxProfit(int[] prices) {
        int min = 0x3f3f3f3f;
        int ans = 0;
        for (int price : prices) {
            min = Math.min(min, price);
            ans = Math.max(ans, price - min);
        }
        return ans;
    }
}
